/*** Constants ***/
const TAXONOMY_TREE_JSON = "http://localhost/nichacactus/taxonomy.php";

/*** Test Data ***/
var tagRoot = new Ext.tree.AsyncTreeNode("Tag");
tagRoot.appendChild(new Ext.tree.AsyncTreeNode("InnerTag"));

/*** Header ***/
var header = new Ext.Panel({
    region: 'north',
    el: 'header',
    autoHeight: true,
    border: false
});

/*** Left ***/
var taxonomyroot = new Ext.tree.AsyncTreeNode({
    text: 'Taxonomy', 
    draggable:false, // disable root node dragging
    id:'taxonomy'
});

var taxonomyTree = new Ext.tree.TreePanel({
    border: false,
    region: 'center',
    
    root: taxonomyroot,
    loader: new Ext.tree.TreeLoader({dataUrl:TAXONOMY_TREE_JSON})

});

var tagTree = new Ext.tree.TreePanel({
    border: false,
    region: 'center',
    
    root: tagRoot
});

var leftPanelTab = new Ext.TabPanel({
    region: 'center',
    
    border: false,
    tabPosition: 'bottom',
    activeTab: 0,
    items: [{
        title: 'Taxonomy',
        layout: 'border',
        items: [taxonomyTree],
        autoScroll:true
    },{
        title: 'Common Names',
        layout: 'border',
        //items: [commonNamesGrid],
        autoScroll:true
    },{
        title: 'Tags',
        layout: 'border',
        items: [tagTree],
        autoScroll:true
    }]
});

var left = new Ext.Panel({
    region: 'west',
    title:'Navigation',
    split:true,
    width: 250,
    minSize: 175,
    maxSize: 400,
    collapsible: true,
    margins:'0 0 5 5',
    
    layout: 'border',
    items: [leftPanelTab]
    
});

//Content
var content = new Ext.TabPanel({
    region: 'center',
    margins:'0 5 5 0',
    
    activeTab: 0,
    items: [{
        title: 'Overview',
        html: 'Overview here',
        autoScroll:true
    },{
        title: 'Content',
        defaultUrl: 'ajaxtest.html',
        closable:true,
        autoScroll:true
    }]
});

/*** Main Entry point ***/
Ext.onReady(function() {

    new Ext.Viewport({
        layout: "border",
        items: [header, left, content]
    });       

});
